﻿using Microsoft.EntityFrameworkCore;

namespace Devonline.AspNetCore;

/// <summary>
/// 数据库上下文扩展操作集合
/// </summary>
public static class DbContextExtensions
{
    /// <summary>
    /// 自动迁移
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public static async Task AutoMigrationAsync(this DbContext context)
    {
        if ((await context.Database.GetPendingMigrationsAsync()).Any())
        {
            await context.Database.MigrateAsync();
        }
    }
}